 

package com.zdkj.subway.stm.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.subway.stm.entity.SwStConductorSettleDetail;
import com.zdkj.subway.stm.service.SwStConductorSettleDetailService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 售票员结算明细表（子表）
 *
 * @author chenbo
 * @date 2020-02-01 19:24:00
 */
@RestController
@AllArgsConstructor
@RequestMapping("/swstconductorsettledetail" )
@Api(value = "swstconductorsettledetail", tags = "售票员结算明细表（子表）管理")
public class SwStConductorSettleDetailController {

    private final  SwStConductorSettleDetailService swStConductorSettleDetailService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param swStConductorSettleDetail 售票员结算明细表（子表）
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public R getSwStConductorSettleDetailPage(Page page, SwStConductorSettleDetail swStConductorSettleDetail) {
        return R.ok(swStConductorSettleDetailService.page(page, Wrappers.query(swStConductorSettleDetail)));
    }


    /**
     * 通过id查询售票员结算明细表（子表）
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public R getById(@PathVariable("id" ) Integer id) {
        return R.ok(swStConductorSettleDetailService.getById(id));
    }

    /**
     * 新增售票员结算明细表（子表）
     * @param swStConductorSettleDetail 售票员结算明细表（子表）
     * @return R
     */
    @ApiOperation(value = "新增售票员结算明细表（子表）", notes = "新增售票员结算明细表（子表）")
    @SysLog("新增售票员结算明细表（子表）" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('stm_sw_st_conductor_settle_detail_add')" )
    public R save(@RequestBody SwStConductorSettleDetail swStConductorSettleDetail) {
        return R.ok(swStConductorSettleDetailService.save(swStConductorSettleDetail));
    }

    /**
     * 修改售票员结算明细表（子表）
     * @param swStConductorSettleDetail 售票员结算明细表（子表）
     * @return R
     */
    @ApiOperation(value = "修改售票员结算明细表（子表）", notes = "修改售票员结算明细表（子表）")
    @SysLog("修改售票员结算明细表（子表）" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('stm_sw_st_conductor_settle_detail_edit')" )
    public R updateById(@RequestBody SwStConductorSettleDetail swStConductorSettleDetail) {
        return R.ok(swStConductorSettleDetailService.updateById(swStConductorSettleDetail));
    }

    /**
     * 通过id删除售票员结算明细表（子表）
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除售票员结算明细表（子表）", notes = "通过id删除售票员结算明细表（子表）")
    @SysLog("通过id删除售票员结算明细表（子表）" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('stm_sw_st_conductor_settle_detail_del')" )
    public R removeById(@PathVariable Integer id) {
        return R.ok(swStConductorSettleDetailService.removeById(id));
    }

}
